﻿Public Class form_load
    Dim kelas As New player
    Dim xTerpilih As String
    Dim xUrutan As Integer

    Public Property urutan As Integer
        Get
            Return xUrutan
        End Get
        Set(ByVal value As Integer)
            xUrutan = value
        End Set
    End Property
    'Dim xWinner(UBound(xSkor)) As String

    Public Sub form_load_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tampil()
    End Sub

    Public Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        For Each i As Object In Me.Controls
            If TypeOf i Is RadioButton Then
                If i.text = "<Empty>" And i.checked = True Then
                    MsgBox("Enter your name first| Asmanipun dereng ditulis")
                ElseIf i.text <> "<Empty>" And i.checked = True Then
                    If RadioButton1.Checked = True Then
                        xTerpilih = RadioButton1.Text

                        xUrutan = 0
                        kelas.urutan = xUrutan
                        formreport.urutan = 0
                        form_level.urutan = 0
                        form_puzzle.urutan = 0
                        formtes.urutan = 0
                        MsgBox("Welcome / Sugeng Rawuh")
                        kelas.Temp = xTerpilih
                        kelas.nama()
                        form_level.Show()
                        Me.Close()
                    End If
                    If RadioButton2.Checked = True Then
                        xTerpilih = RadioButton2.Text
                        MsgBox("Welcome / Sugeng Rawuh")
                        kelas.Temp = xTerpilih
                        xUrutan = 1
                        'kelas.urutan = 1
                        kelas.nama()
                        form_level.Show()
                        Me.Close()
                    End If
                    If RadioButton3.Checked = True Then
                        xTerpilih = RadioButton3.Text

                        MsgBox("Welcome / Sugeng Rawuh")
                        kelas.Temp = xTerpilih

                        'kelas.urutan = 2
                        xUrutan = 2
                        kelas.nama()
                       
                        form_level.Show()
                        Me.Close()
                    End If

                    If RadioButton4.Checked = True Then
                        xTerpilih = RadioButton4.Text
                        'Label1.Text = kelas.Temp
                        MsgBox("Welcome / Sugeng Rawuh")
                        kelas.Temp = xTerpilih

                        'kelas.urutan = 3
                        xUrutan = 3
                        kelas.nama()

                        form_level.Show()
                        Me.Close()
                    End If


                End If
            End If
        Next

    End Sub

    Private Sub PictureBox2_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox2.Click

        Form_enter.Show()
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    Public Sub tampil()
        Dim xSimpan() As String = Split(System.IO.File.ReadAllText("jumlahplayer.txt"), vbCrLf)
        Dim xJumlah As Integer = xSimpan.Count
        Dim xUser(4) As String
        For i As Integer = 0 To UBound(xSimpan)
            ' Dim xNamaPlayer() As String = Split(xSimpan(i), ",")
            If xSimpan.Count = 0 Then
                xUser(0) = ""
                xUser(1) = ""
                xUser(2) = ""
                xUser(3) = ""
            Else
                xUser(i) = xSimpan(i)
            End If
        Next
        If xUser(0) <> "" Then
            RadioButton1.Text = xUser(0)
        End If
        If xUser(1) <> "" Then
            RadioButton2.Text = xUser(1)
        End If
        If xUser(2) <> "" Then
            RadioButton3.Text = xUser(2)
        End If
        If xUser(3) <> "" Then
            RadioButton4.Text = xUser(3)
        End If
        

    End Sub

   

    Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click


        If RadioButton1.Checked = True Then
            kelas.urutan = 0
            kelas.hapus()

        ElseIf RadioButton2.Checked = True Then
            kelas.urutan = 1
            kelas.hapus()

        ElseIf RadioButton3.Checked = True Then
            kelas.urutan = 2
            kelas.hapus()

        ElseIf RadioButton4.Checked = True Then
            kelas.urutan = 3
            kelas.hapus()
        End If
        tampil()
        Me.Close()
        Form_enter.Show()
    End Sub
End Class